package com.xishu.config;

import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.ClassUtils;

public class Config {
    private static Logger logger = LoggerFactory.getLogger(Config.class);

    private static PropertiesConfiguration config;

    private static Config instance = new Config();

    public static String getLocalResourcePath() {
        return ClassUtils.getDefaultClassLoader().getResource("").getPath();
    }

    public static Config getInstance() {

        return instance;
    }

    public String dolaShowVersion() {
        return config.getString("dola.show.version", "1.5.1");
    }

    public String localConfigPath() {
        return System.getProperty("local.config.path");
    }

    /**
     * 单节点，目前需要做的是
     * S3，OSS
     * 分布锁式
     * 选主，与不用选主
     * 发送邮件，是用阿里云还是亚马逊的
     *
     * @return
     */
    public boolean isSingleNode() {
        String property = System.getProperty("single.node");
        return StringUtils.equalsIgnoreCase(property, "true");
    }

    public static boolean isLocalNode() {
        String property = System.getProperty("local.node");
        return StringUtils.equalsIgnoreCase(property, "true");
    }

    public static String getConfigPath() {
        String configPath = System.getProperty("config.path");
        return configPath;
    }

    public static String loadConfigPath() {
        String configPath = getConfigPath();
        if (configPath != null) {
            return configPath + "/";
        }

        if (isLocalNode()) {
            return getLocalResourcePath();
        }

        if (isWindows()) {
            return getLocalResourcePath();
        }

        return Constant.RESOURCE_PATH;
    }

    public boolean localLock() {
        return config.getBoolean("local.lock", false);
    }

    private Config() {
        try {
            if (StringUtils.isNotEmpty(localConfigPath())) {
                String configFile = localConfigPath();
                config = new PropertiesConfiguration(configFile);
                config.setEncoding("utf8");
                config.setReloadingStrategy(new FileChangedReloadingStrategy());
                config.load(configFile);
                return;
            } else {
                String configPath = loadConfigPath();
                String configFile = configPath + "config.properties";
                config = new PropertiesConfiguration(configFile);
                config.setEncoding("utf8");
                config.setReloadingStrategy(new FileChangedReloadingStrategy());
                config.load(configFile);
                return;
            }
        } catch (Exception e) {
            logger.error("", e);
        }
    }

    /**
     * 上传下载均从该目录获取
     */
    public static final String DOCUMENT_DIR = "/opt/files/";

    public static String getEsIp() {
        return "127.0.0.1";
    }

    public static String getEsAuthValue() {
        return "Basic ZWxhc3RpYzpuYmEhMTIzNDU=";
    }

    public static final String ES_AUTH_KEY = "Authorization";

    public String getRedisServer() {
        return config.getString("redis.server.ip", "127.0.0.1");
    }

    public static int getRedisPort() {
        return config.getInt("redis.port", 6379);
    }

    public static String getRedisPassword() {
        return config.getString("redis.password", "fanglangkeji123fanglangkejifanglangkeji456fanglangkejifanglangkeji789fanglangkejifanglangkejiedcfanglangkeji");
    }

    public static int getCacheExpireTime() {
        return 1800;
    }


    public int getShowPageSize() {
        return config.getInt("show.page.size", 100);
    }

    public String label_tang_shi_take_out(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.tang.shi.take.out", "堂食外賣");
        } else {
            return config.getString("print.label.tang.shi.take.out.en", "堂食外賣");
        }
    }

    public String label_tang_shi(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.tang.shi", "堂食");
        } else {
            return config.getString("print.label.tang.shi.en", "堂食");
        }
    }

    public String label_take_out(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.take.out", "外賣");
        } else {
            return config.getString("print.label.take.out.en", "外賣");
        }
    }

    public String label_take_out_plat(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.take.out.plat", "FoodPanda");
        } else {
            return config.getString("print.label.take.out.plat.en", "FoodPanda");
        }

    }

    public String label_take_out_bottom(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.take.out.bottom", "外賣");
        } else {
            return config.getString("print.label.take.out.bottom.en", "Takeout");
        }
    }

    public String label_take_out_plat_bottom(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.take.out.plat.bottom", "FoodPanda");
        } else {
            return config.getString("print.label.take.out.plat.bottom.en", "FoodPanda");
        }
    }

    public String label_not_have_take_out_plat(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.not.have.take.out.plat", "(不含外賣平臺)");
        } else {
            return config.getString("print.label.not.have.take.out.plat.en", "(不含外賣平臺)");
        }
    }

    public String label_cash(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.cash", "現金收款");
        } else {
            return config.getString("print.label.cash.en", "現金收款");
        }
    }

    public String label_weixin(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.weixin", "微信");
        } else {
            return config.getString("print.label.weixin.en", "微信");
        }
    }

    public String label_alipay(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.alipay", "支付宝");
        } else {
            return config.getString("print.label.alipay.en", "支付宝");
        }
    }

    public String label_total_cash(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.total.cash", "營業總額：");
        } else {
            return config.getString("print.label.total.cash.en", "營業總額：");
        }
    }

    public String label_order_catalog(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.order.catalog", "訂單分類");
        } else {
            return config.getString("print.label.order.catalog.en", "訂單分類");
        }
    }

    public String label_order_count(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.order.count", "訂單量");
        } else {
            return config.getString("print.label.order.count.en", "訂單量");
        }
    }

    public String label_sale(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.sale", "銷售額");
        } else {
            return config.getString("print.label.sale.en", "銷售額");
        }
    }

    public String label_catalog(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.catalog", "品類");
        } else {
            return config.getString("print.label.catalog.en", "品類");
        }
    }

    public String label_sale_count(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.sale", "銷售額");
        } else {
            return config.getString("print.label.sale.en", "銷售額");
        }
    }

    public String label_detail_report(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.detail.report", "詳細報告");
        } else {
            return config.getString("print.label.detail.report.en", "詳細報告");
        }
    }

    public String label_pay_type(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.pay.type", "付款方式");
        } else {
            return config.getString("print.label.pay.type.en", "付款方式");
        }
    }

    public String label_fee(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.fee", "金額");
        } else {
            return config.getString("print.label.fee.en", "金額");
        }
    }

    public String label_per_day_order(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.per.day.order", "單號");
        } else {
            return config.getString("print.label.per.day.order.en", "單號");
        }
    }

    public String label_order_label(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.order.label", "單");
        } else {
            return config.getString("print.label.order.label.en", "單");
        }
    }

    public String label_restaurant_tang_shi(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.restaurant.tang.shi", "餐廳堂食");
        } else {
            return config.getString("print.label.restaurant.tang.shi.en", "餐廳堂食");
        }
    }

    public String label_restaurant_take_out(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.restaurant.take.out", "餐廳外賣");
        } else {
            return config.getString("print.label.restaurant.take.out.en", "餐廳外賣");
        }
    }

    public String label_date(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.date", "日期：");
        } else {
            return config.getString("print.label.date.en", "日期：");
        }
    }

    public String label_phone(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.phone", "電話：");
        } else {
            return config.getString("print.label.phone.en", "電話：");
        }
    }

    public String label_packing_order(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.packing.order", "上菜單/打包單");
        } else {
            return config.getString("print.packing.order.en", "Packaging List");
        }
    }


    public String label_address(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.address", "地址：");
        } else {
            return config.getString("print.label.address.en", "地址：");
        }
    }

    public String label_detail_address(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.detail.address", "詳細地址：");
        } else {
            return config.getString("print.label.detail.address.en", "詳細地址：");
        }
    }

    public String label_wait_time(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.wait.time", "排隊時間：");
        } else {
            return config.getString("print.label.wait.time.en", "排隊時間：");
        }
    }

    public String label_food_table_no(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.food.table.no", "桌號：");
        } else {
            return config.getString("print.label.food.table.no.en", "桌號：");
        }
    }

    public String label_waiter(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.waiter", "負責員工：");
        } else {
            return config.getString("print.label.waiter.en", "負責員工：");
        }
    }

    public String label_open_time(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.open.time", "開台時間：");
        } else {
            return config.getString("print.label.open.time.en", "開台時間：");
        }
    }

    public String label_take_out_time(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.take.out.time", "開單時間：");
        } else {
            return config.getString("print.label.take.out.time.en", "開單時間：");
        }
    }

    public String label_dinner_number(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.dinner.number", "就餐人數：");
        } else {
            return config.getString("print.label.dinner.number.en", "就餐人數：");
        }
    }

    public String label_waiter_name(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.waiter.name", "服務員：");
        } else {
            return config.getString("print.label.waiter.name.en", "Server:");
        }
    }

    public String label_person(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.person", "人");
        } else {
            return config.getString("print.label.person.en", "");
        }
    }

    public String label_scan(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.scan", "掃碼點餐");
        } else {
            return config.getString("print.label.scan.en", "Serve End QR Code Notice");
        }
    }

    public String label_pay_first(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.pay.first", "(麻煩下單後先付款)");
        } else {
            return config.getString("print.label.pay.first.en", "(麻煩下單後先付款)");
        }
    }


    public String label_table(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.table", "桌");
        } else {
            return config.getString("print.label.table.en", " table");
        }
    }

    public String label_add_item(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.add.item", "加菜");
        } else {
            return config.getString("print.label.add.item.en", "加菜");
        }
    }

    public String label_order_time(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.order.time", "時間：");
        } else {
            return config.getString("print.label.order.time.en", "下單時間：");
        }
    }

    public String label_none(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.none", "無");
        } else {
            return config.getString("print.label.none.en", "無");
        }
    }

    public String label_remarks(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.remarks", "備註：");
        } else {
            return config.getString("print.label.remarks.en", "備註：");
        }
    }

    public String label_name(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.name", "名稱");
        } else {
            return config.getString("print.label.name.en", "名稱");
        }
    }

    public String label_count(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.label.count", "数量");
        } else {
            return config.getString("print.label.count.en", "数量");
        }
    }

    public String label_line_up_no(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.line.up.no", "您的排队號碼：");
        } else {
            return config.getString("print.line.up.no.en", "您的排队號碼：");
        }
    }

    public String label_current_no(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.current.no", "下一個叫號：");
        } else {
            return config.getString("print.current.no.en", "當前叫號：");
        }
    }

    public String label_wait_no(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.wait.no", "等候桌數：");
        } else {
            return config.getString("print.wait.no.en", "等候桌數：");
        }
    }

    public String label_wait_info(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.wait.wait.info", "掃碼查看排隊信息");
        } else {
            return config.getString("print.wait.wait.info.en", "Queue QR Code Notice");
        }
    }

    public String label_take_no(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.take.no", "取餐碼：");
        } else {
            return config.getString("print.take.no.en", "取餐碼：");
        }
    }

    public String label_contact(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("label.contact", "電話：");
        } else {
            return config.getString("label.contact.en", "Phone:");
        }
    }

    public String label_userName(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("label.user.name", "姓名：");
        } else {
            return config.getString("label.user.name.en", "Name:");
        }
    }

    public String label_small_total(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.small.total", "小計：");
        } else {
            return config.getString("print.small.total.en", "小計：");
        }
    }

    public String label_should_pay(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("label.should.pay", "應付：");
        } else {
            return config.getString("label.should.pay.en", "You Pay:");
        }
    }

    public String label_service_fee(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.service.fee", "服務費：");
        } else {
            return config.getString("print.service.fee.en", "服務費：");
        }
    }

    public String label_delivery_fee(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.delivery.fee", "配送费：");
        } else {
            return config.getString("print.delivery.fee.en", "配送费：");
        }
    }

    public String label_foodPanda_pay(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.foodPanda.pay", "FoodPanda支付：");
        } else {
            return config.getString("print.foodPanda.pay.en", "FoodPandaPay：");
        }
    }


    public String label_consumptionTax_fee(Boolean zh, Double consumptionTax) {
        if (zh == null || zh) {
            String string = config.getString("print.consumption.tax.fee", "消费税(%s%%)：");
            return String.format(string, consumptionTax);
        } else {
            String string = config.getString("print.consumption.tax.fee.en", "Sales Tax(%s%%):");
            return String.format(string, consumptionTax);
        }
    }

    public String label_tips_fee(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.tips.fee", "小費：");
        } else {
            return config.getString("print.tips.fee.en", "Tips:");
        }
    }

    public String us_total(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("us.total", "總計");
        } else {
            return config.getString("print.tips.fee.en", "Total");
        }
    }

    public String string_consumptionTax_fee(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("string.consumption.tax.fee", "消费税(%s%%)");
        } else {
            return config.getString("string.consumption.tax.fee.en", "Sales Tax(%s%%)");
        }
    }


    public String label_lunch_box(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.lunch.box", "餐盒費：");
        } else {
            return config.getString("print.lunch.box.en", "餐盒費：");
        }
    }

    public String label_order_total(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.order.total", "總計：");
        } else {
            return config.getString("print.order.total.en", "總計：");
        }
    }

    public String label_weixin_pay(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.weixin.pay", "微信");
        } else {
            return config.getString("print.weixin.pay.en", "微信支付");
        }
    }

    public String label_alipay_pay(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.alipay.pay", "支付寶");
        } else {
            return config.getString("print.alipay.pay.en", "支付宝支付");
        }
    }

    public String label_cash_pay(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.cash.pay", "現金");
        } else {
            return config.getString("print.cash.pay.en", "现金支付");
        }
    }

    public String label_union_pay(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.union.pay", "銀聯");
        } else {
            return config.getString("print.union.en", "UnionPay");
        }
    }

    public String label_ba_da_tong(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.ba.da.tong.pay", "八達通");
        } else {
            return config.getString("print.ba.da.tong.pay.en", "Octopus");
        }
    }

    public String label_american_express(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.Amex.pay", "Amex");
        } else {
            return config.getString("print.Amex.pay.en", "Amex");
        }
    }

    public String label_credit_card(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.credit.card", "信用卡");
        } else {
            return config.getString("print.credit.card", "Credit Card");
        }
    }

    public String label_remark_print(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("label.remark.print", "备注：");
        } else {
            return config.getString("label.remark.print.en", "remark:");
        }
    }

    public String label_cheque(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.cheque", "支票");
        } else {
            return config.getString("print.cheque.card", "Cheque");
        }
    }

    public String label_zhifu_type(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.zhifu.type", "支付方式：");
        } else {
            return config.getString("print.zhifu.type.en", "支付方式：");
        }
    }

    public String label_unpay(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.unpay", "未支付");
        } else {
            return config.getString("print.unpay.en", "未支付");
        }
    }

    public String label_shopInfo(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.shop.info", "商家特別信息：");
        } else {
            return config.getString("print.shop.info.en", "商家特別信息：");
        }
    }

    public String label_discount_info(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.discount.info", "优惠券：");
        } else {
            return config.getString("print.discount.info.en", "优惠券：");
        }
    }

    public String label_take_out_discount_fee(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.take.out.discount.info", "外賣折扣：");
        } else {
            return config.getString("print.take.out.discount.fee.en", "Take-away Discount:");
        }
    }

    public String label_satisfy(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.satisfy", "您的消费满");
        } else {
            return config.getString("print.satisfy.en", "您的消费满");
        }
    }

    public String label_validate_day(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.validate.day", "有效期至");
        } else {
            return config.getString("print.validate.day.en", "有效期至");
        }
    }

    public String label_satisfy_and_cut(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("print.satisfy.and.cut", "送您一張滿$%s减$%s的優惠券");
        } else {
            return config.getString("print.satisfy.and.cut.en", "送您一張滿%s减%s的優惠券");
        }
    }

    public String label_cash_receive(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("label.cash.receive", "現金付款：");
        } else {
            return config.getString("label.cash.receive.en", "Cash Received:");
        }
    }

    public String label_cash_return(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("label.cash.return", "找贖：");
        } else {
            return config.getString("label.cash.return.en", "Cash Change:");
        }
    }

    public String close_report_pay_type(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.pay.type", "支付方式");
        } else {
            return config.getString("close.report.pay.type.en", "DEPT");
        }
    }

    public String close_report_tang_shi(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.tang.shi", "堂食");
        } else {
            return config.getString("close.report.tang.shi.en", "HERE");
        }
    }

    public String close_report_take_out(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.take.out", "外賣");
        } else {
            return config.getString("close.report.take.out.en", "TAKE OUT");
        }
    }

    public String close_report_total(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.total", "總額");
        } else {
            return config.getString("close.report.total.en", "TOTAL");
        }
    }

    public String close_report_pay_type_1(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.pay_type.1", "微信");
        } else {
            return config.getString("close.report.pay_type.1.en", "WeChat Pay");
        }
    }

    public String close_report_pay_type_2(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.pay_type.2", "支付寶");
        } else {
            return config.getString("close.report.pay_type.2.en", "Alipay");
        }
    }

    public String close_report_pay_type_3(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.pay_type.3", "Mastercard");
        } else {
            return config.getString("close.report.pay_type.3.en", "Mastercard");
        }
    }

    public String close_report_pay_type_4(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.pay_type.4", "Visa");
        } else {
            return config.getString("close.report.pay_type.4.en", "Visa");
        }
    }

    public String close_report_pay_type_5(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.pay_type.5", "現金");
        } else {
            return config.getString("close.report.pay_type.5.en", "Cash");
        }
    }

    public String close_report_pay_type_6(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.pay_type.6", "Apple Pay");
        } else {
            return config.getString("close.report.pay_type.6.en", "Apple Pay");
        }
    }

    public String close_report_pay_type_7(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.pay_type.7", "Google Pay");
        } else {
            return config.getString("close.report.pay_type.7.en", "Google Pay");
        }
    }

    public String close_report_pay_type_8(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.pay_type.8", "八達通");
        } else {
            return config.getString("close.report.pay_type.8.en", "Octopus");
        }
    }

    public String close_report_pay_type_9(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.pay_type.9", "銀聯");
        } else {
            return config.getString("close.report.pay_type.9.en", "UnionPay");
        }
    }

    public String close_report_pay_type_10(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.pay_type.10", "Amex");
        } else {
            return config.getString("close.report.pay_type.10.en", "Amex");
        }
    }

    public String close_report_pay_type_11(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.pay_type.11", "Stripe");
        } else {
            return config.getString("close.report.pay_type.11.en", "Stripe");
        }
    }

    public String close_report_take_out_plat(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.take.out.plat", "外賣平台");
        } else {
            return config.getString("close.report.take.out.plat.en", "Delivery Platform");
        }
    }

    public String close_report_total_sale(Boolean zh) {
        if (zh == null || zh) {
            if (isUsVersion()) {
                return "總計";
            } else {
                return config.getString("close.report.take.out.plat", "營業額");
            }

        } else {
            return config.getString("close.report.take.out.plat.en", "Total");
        }
    }

    public String close_report_service_fee(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.service.fee", "服務費");
        } else {
            return config.getString("close.report.service.fee.en", "Service Charge");
        }
    }

    public String close_tips_fee(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.tips.fee", "小費");
        } else {
            return config.getString("close.tips.fee.zh", "Tips");
        }
    }

    public String us_tips_fee(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("us.tips.fee", "小費");
        } else {
            return config.getString("us.tips.fee.en", "TIP");
        }
    }

    public String close_report_package_fee(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.package.fee", "餐盒費");
        } else {
            return config.getString("close.report.package.fee.en", "Packing Fee");
        }
    }

    public String close_report_take_out_fee(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.take.out.fee", "外賣折扣");
        } else {
            return config.getString("close.report.take.out.fee.en", "Take Out Discount");
        }
    }

    public String close_report_ticket_fee(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.ticket.fee", "優惠券");
        } else {
            return config.getString("close.report.ticket.fee.en", "Coupon");
        }
    }

    public String close_report_user_cost(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.user.cost.fee", "淨營收");
        } else {
            return config.getString("close.report.ticket.fee.en", "NET SALE");
        }
    }

    public String close_report_unpaid(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.unpaid", "未支付");
        } else {
            return config.getString("close.report.unpaid.en", "Unpaid");
        }
    }

    public String close_report_return_cash(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.return.cash", "已退款");
        } else {
            return config.getString("close.report.return.cash.en", "Refunded");
        }
    }

    public String close_report_dinners(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.dinners", "客流量");
        } else {
            return config.getString("close.report.dinners.en", "Guest");
        }
    }

    public String close_report_order_number(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.order.number", "訂單量");
        } else {
            return config.getString("close.report.order.number.en", "Transactions");
        }
    }

    public String close_report_delete_order_number(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.delete.order.number", "删除訂單");
        } else {
            return config.getString("close.report.delete.order.number.en", "Deleted Check");
        }
    }

    public String close_report_delete_order_item_number(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.delete.order.item.number", "删除菜品");
        } else {
            return config.getString("close.report.delete.order.item.number.en", "Deleted Dish");
        }
    }

    public String close_report_tang_shi_order_number(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.tang.shi.order.number", "餐廳堂食");
        } else {
            return config.getString("close.report.tang.shi.order.number.en", "Dine Here");
        }
    }

    public String close_report_take_out_order_number(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.take.out.order.number", "餐廳外賣");
        } else {
            return config.getString("close.report.take.out.order.number.en", "Take Out");
        }
    }

    public String close_report_take_out_plat_order_number(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.take.out.plat.order.number", "外賣平台");
        } else {
            return config.getString("close.report.take.out.order.plat.number.en", "Delivery Platform");
        }
    }

    public String close_report_detail_report_title(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.detail.report.title", "詳細報告");
        } else {
            return config.getString("close.report.detail.report.title.en", "Detail Report");
        }
    }

    public String close_customer_report_title(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.customer.report.title", "會員報告");
        } else {
            return config.getString("close.customer.report.title.en", "Membership Report");
        }
    }

    public String close_report_order_number_title(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.order.number.title", "單號");
        } else {
            return config.getString("close.report.order.number.title.en", "Check #");
        }
    }

    public String customer_report_pay_type_title(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("customer.report.pay.type.title", "支付方式");
        } else {
            return config.getString("customer.report.pay.type.title.en", "支付方式");
        }
    }

    public String customer_report_vip_title(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("customer.report.vip.title", "會員費");
        } else {
            return config.getString("customer.report.vip.title.en", "VIP Fee");
        }
    }

    public String customer_report_vip_sale_title(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("customer.report.vip.and.sale.title", "會員+銷售");
        } else {
            return config.getString("customer.report.vip.and.sale.title.en", "VIP+Sales");
        }
    }

    public String customer_report_vip_total_title(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("customer.report.vip.total.title", "總計");
        } else {
            return config.getString("customer.report.vip.total.title.en", "Total");
        }
    }

    public String close_report_pay_type_title(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.pay.type.title", "支付方式");
        } else {
            return config.getString("close.report.pay.type.title.en", "Pay By");
        }
    }

    public String close_report_sales_title(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.sales.title", "金额");
        } else {
            return config.getString("close.report.sales.title.en", "Amount");
        }
    }

    public String expire_order_label(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("expire.order.label", "(失效)");
        } else {
            return config.getString("expire.order.label.en", "(exp)");
        }
    }

    public String close_report_has_tax(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.has.tax", "(含税)");
        } else {
            return config.getString("close.report.has.tax.en", "(with tax & service)");
        }
    }

    public String close_report_net_sale(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.net.sale", "凈營收");
        } else {
            return config.getString("close.report.net.sale.en", "Net Sales");
        }
    }

    public String close_report_net_sale_with_tax(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.net.sale.with.tax", "營收");
        } else {
            return config.getString("close.report.net.sale.with.tax.en", "Sales");
        }
    }

    public String close_report_without_tax(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.has.tax", "(不含税)");
        } else {
            return config.getString("close.report.has.tax.en", "(without tax & service)");
        }
    }

    public String close_report_with_tax(Boolean zh) {
        if (zh == null || zh) {
            return config.getString("close.report.has.with.tax", "(含税)");
        } else {
            return config.getString("close.report.has.tax.with.en", "(with tax)");
        }
    }

    /**
     * 订单数据库的个数
     *
     * @return
     */
    public int getOrderDbNumber() {
        return config.getInt("order.db.number", 2);
    }

    public String getUploadTmpPath() {
        String uploadTmpPath = System.getProperty("uploadTmpPath");

        if (uploadTmpPath != null) {
            return uploadTmpPath;
        }

        if (isWindows()) {
            return "d:/tmp";
        }

        return config.getString("upload.tmp.path", "d:/tmp");
    }

    public boolean isAliyun() {
        return config.getBoolean("is.aliyun", false);
    }

    public boolean isCheckStripeConfigCheck() {
        return config.getBoolean("is.check.stripe.config.check", true);
    }

    public String getOSSEndPoint() {
        return config.getString("oss.endpoint.", "oss-cn-zhangjiakou.aliyuncs.com");
    }

    public String getProductBucketEndpoint() {
        if (isAliyun()) {
            return config.getString("product.bucket.endpoint", "cd-jinchen-public.oss-cn-zhangjiakou.aliyuncs.com");
        } else {
            return getS3BucketEndPoint();
        }

    }

    public String getS3BucketEndPoint() {
        if (isUsVersion()) {
            return config.getString("s3.bucket.endpoint", "s3.us-west-1.amazonaws.com/dola.us");
        }

        return config.getString("s3.bucket.endpoint", "s3.ap-east-1.amazonaws.com/dola.hk");
    }

    public String getS3BucketName() {
        if (isUsVersion()) {
            return config.getString("s3.bucket.name", "dola.us");
        } else {
            return config.getString("s3.bucket.name", "dola.hk");
        }

    }

    public String getOssAk() {
        return config.getString("oss.ak");
    }

    public String getAwsAk() {
        return config.getString("aws.ak");
    }

    public String getOssSk() {
        return config.getString("oss.sk");
    }

    public String getAwsSk() {
        return config.getString("aws.sk");
    }

    public String getPublicBucketName() {
        return config.getString("public.bucket.name");
    }

    public String getString(String key) {
        return config.getString(key);
    }

    public int getInt(String key) {
        return config.getInt(key);
    }

    public boolean getBool(String key) {
        return config.getBoolean(key);
    }

    public static boolean isWindows() {
        return System.getProperties().getProperty("os.name").toUpperCase().indexOf("WINDOWS") != -1;
    }

    public String swaggerPackage() {
        if (isWindows()) {
            return "com.xishu.bo";
        } else if (isLocalNode() || isSingleNode()) {
            return "com.xishu";
        } else {
            return "com.xishu.bo";
        }
    }

    public String getEmailSk() {
        return config.getString("email.sk");
    }

    public String getEmailAk() {
        return config.getString("email.ak");
    }

    /**
     * 获取终端
     *
     * @return
     */
    public String getEndPoint() {
        //http://localhost:9527
        if (this.isLocalNode()) {
            return "http://localhost:8888";
        } else if (this.isSingleNode()) {
            return "https://xishu.3g48.com";
//            return "http://39.98.198.162:9999";
        } else if (this.dolaTest() && isHkVersion()) {
            return "https://test.dolatechnology.com";
        } else if (this.dolaTest() && isUsVersion()) {
            return "https://test.us.dolatechnology.com";
        }

        if (this.isUsVersion()) {
            return "https://app.us.dolatechnology.com";
        }

        return "https://app.dolatechnology.com";
    }

    public String getCustomerEndPoint() {
        if (this.isLocalNode()) {
            return "http://localhost:8888";
        } else if (this.isSingleNode()) {
            return "https://xishu.3g48.com";
        } else if (this.dolaTest() && isHkVersion()) {
            return "https://test.dolatechnology.com";
        } else if (this.dolaTest() && isUsVersion()) {
            return "https://test.us.dolatechnology.com";
        }

        if (isUsVersion()) {
            return "https://app.us.dolatechnology.com";
        }

        return "https://app.dolatechnology.com";
    }


    public String getCancelOrderTime() {
        return config.getString("cancel.order.time", "01");
    }

    public String getZkServer() {
        if (isAliyun()) {
            return config.getString("zk.server", "39.98.198.162");
        } else {
            return "127.0.0.1";
        }
    }

    public int getZkPort() {
        return config.getInt("zk.port", 2181);
    }

    public String getZkPath() {
        return config.getString("zk.path", "/dola");
    }

    public int defaultOnlineTouchDeviceNumber() {
        return config.getInt("default.online.touch.device.number", 2);
    }

    public boolean isMaster() {
        if (isSingleNode() || isLocalNode()) {
            return true;
        }

        return false;
    }

    public int touchDeviceExpireTime() {
        return config.getInt("touch.device.expire.time", 300);
    }

    /**
     * 校验金额的时间间隔
     *
     * @return
     */
    public long verifyCashTime() {
        return config.getLong("verify.cash.time", 5 * 60 * 1000);
    }

    public boolean mockPayTypeSwitch() {
        return config.getBoolean("mock.pay.type", false);
    }

    public String homeQrCode() {
        return config.getString("hoem.qr.code", getEndPoint() + "/home/");
    }

    /**
     * 扫描订单的间隔
     *
     * @return
     */
    public Long scanOrderInterval() {
        return config.getLong("scan.order.interval", 5000);
    }

    /**
     * 单个订单的最大菜品数
     *
     * @return
     */
    public int oneOrderItemMaxNumber() {
        return config.getInt("one.order.item.max.number", 20);
    }

    public boolean stockManageOpen() {
        return config.getBoolean("stock.manage", false);
    }

    /**
     * 默认5分钟内必须支付
     *
     * @return
     */
    public long confirmExpireTime() {
        return config.getLong("confirm.expire.time", 5 * 60 * 1000);
    }

    /**
     * 默认5分钟
     *
     * @return
     */
    public long getLockCashTime() {
        return config.getLong("lock.cash.time", 1000 * 90);
    }

    public boolean reportOpen() {
        return config.getBoolean("report.open", false);
    }

    /**
     * @return
     */
    public int cacheReportTime() {
        return config.getInt("cache.report.time", 5);
    }

    /**
     * 在线人数刷新到数据库的时间
     *
     * @return
     */
    public long onlineCacheToDbTime() {
        return config.getLong("online.cache.to.db.time", 5 * 60 * 1000);
    }

    /**
     * 付款方式的锁定时间
     *
     * @return
     */
    public long getPayTypeLockTime() {
        return config.getLong("pay.type.lock.time", 1000 * 90);
    }

    public boolean canPrint() {
        return config.getBoolean("can.print", false);
    }

    /**
     * 香港测试环境
     *
     * @return
     */
    public boolean dolaTest() {
        return config.getBoolean("dola.test", false);
    }

    public int qrCodeDisableAddNewOrderPayFirst() {
        return config.getInt("qrCodeDisableAddNewOrderPayFirst", 45);
    }

    public boolean partServiceOpen() {
        return config.getBoolean("part.pay.service.open", true);
    }

    public int passwordMaxWrongNumber() {
        return config.getInt("password.max.wrong.number", 8);
    }

    public boolean visitTimeOpen() {
        return config.getBoolean("visit.time.open", false);
    }

    public long visitLimitTime() {
        return config.getLong("visit.limit.time", 500);
    }

    public String recaptchaKey() {
        return config.getString("recaptcha.key", "a165887df87815eba5756bda00c288f880c2002c0a548f65047d270caf71379edf507caa3eba9d0830423777f11bdb3a");
    }

    public String getDolaVersion() {
        return config.getString("dola.service.version", "hk");
    }

    public boolean isUsVersion() {
        String dolaVersion = getDolaVersion();
        return "us".equalsIgnoreCase(dolaVersion);
    }

    public boolean isHkVersion() {
        String dolaVersion = getDolaVersion();
        return "hk".equalsIgnoreCase(dolaVersion);
    }

    public int customerCodeValidTime() {
        return config.getInt("customer.code.valid.time", 60 * 10);
    }

    public boolean quotaOpen() {
        return config.getBoolean("quota.open", true);
    }

    public int ticketDescriptionLength() {
        return config.getInt("ticket.description.length", 200);
    }

    public boolean checkQuota() {
        return config.getBoolean("check.quota", false);
    }

    public String vip_renew_task_name_zh() {
        return config.getString("vip.renew.task.name.zh", "vip续费邮件");
    }

    public String vip_renew_task_name_en() {
        return config.getString("vip.renew.task.name.en", "vip续费邮件");
    }

    public String birthday_task_name_zh() {
        return config.getString("birthday.task.name.zh", "生日邮件");
    }

    public String birthday_task_name_en() {
        return config.getString("birthday.task.name.en", "生日邮件");
    }

    public boolean closeSystemBusy() {
        return config.getBoolean("close.system.busy", false);
    }

    public boolean forceUpdateCompanyMainItem() {
        return config.getBoolean("force.update.company.main.item", false);
    }

    public boolean upgradePayType() {
        return config.getBoolean("upgrade.pay.type", false);
    }

    public boolean upgradePayTypeMapping() {
        return config.getBoolean("upgrade.pay.type.mapping", false);
    }

    public long getPaymentExpireTime() {
        return config.getLong("payment.expire.time", 60);
    }

    public boolean upgradeSetMenuItemNumber() {
        return config.getBoolean("upgrade.set.menu.item.number", false);
    }

    public boolean mockStripeTerminal() {
        return config.getBoolean("mock.stripe.terminal", false);
    }

    public boolean testCapture() {
        return config.getBoolean("test.capture", false);
    }

    public long captureAmount() {
        return config.getLong("capture.amount", 123L);
    }

    public boolean mockCaptureOk() {
        return config.getBoolean("mock.capture.ok", false);
    }

    public boolean mockStripeCaptureError() {
        return config.getBoolean("mock.stripe.capture.error", false);
    }

    public long duplicationRequestTime() {
        return config.getLong("duplication.request.time.check", 1000);
    }

    public boolean performanceTest() {
        return config.getBoolean("performance.test", false);
    }

    public int printerMaxByteSize() {
        return config.getInt("printer.max.byte.size", 4000);
    }

    public boolean addItemUpdateTime() {
        return config.getBoolean("add.item.update.time", false);
    }

    public boolean httpProxy() {
        return config.getBoolean("http.proxy", false);
    }

    public boolean configFoodPandaPrice() {
        return config.getBoolean("config.food.panda.price", true);
    }

    public boolean sendToFoodPanda() {
        return config.getBoolean("send.to.food.panda", true);
    }

    public boolean kitchenReceiptSpacing() {
        return config.getBoolean("kitchen.receipt.spacing", true);
    }

    /**
     * 加入到购物车里，多长时间范围内都算作是重复的请求
     *
     * @return
     */
    public long addToCartDuplicateRequestTime() {
        return config.getLong("add.to.cart.duplication.request.time", 1000l);
    }

    public boolean onlyOneScenePrice() {
        return config.getBoolean("only.one.scene.price", false);
    }

    public boolean onlyScenePrice() {
        return config.getBoolean("only.scene.price", false);
    }

    public boolean foodPandaToFixShop() {
        return config.getBoolean("food.panda.to.fix.shop", false);
    }

    public int foodPandaToFixShopId() {
        return config.getInt("food.panda.to.fix.shop.id", 0);
    }

    public boolean deployCluster() {
        return config.getBoolean("cluster.deploy", false);
    }

    public boolean upgradeItemSceneMapping() {
        return config.getBoolean("upgrade.item.scene.mapping", false);
    }

    public boolean foodpandaItemAvailable() {
        return config.getBoolean("foodpanda.item.available", false);
    }

    public boolean upgradeUserPosPrivilege() {
        return config.getBoolean("upgrade.user.pos.privilege", false);
    }
}
